package com.ruoyi.project.jxc.service.impl;

import com.ruoyi.project.jxc.domain.JxcPurchase;
import com.ruoyi.project.jxc.domain.JxcSup;
import com.ruoyi.project.jxc.mapper.JxcPurMapper;
import com.ruoyi.project.jxc.service.IJxcPurService;
import com.ruoyi.project.jxc.service.IJxcSupService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class JxcPurServiceImpl implements IJxcPurService {
    @Autowired
    private JxcPurMapper purMapper;
    @Autowired
    private IJxcSupService supService;
    @Override
    public List<JxcPurchase> selectPurList(JxcPurchase pur) {
        List<JxcPurchase> jxcPurchases = purMapper.selectPurList(pur);
        for (JxcPurchase jxc:jxcPurchases
             ) {
            Long supId = jxc.getSupId();
            JxcSup jxcSup = supService.selectSupById(supId);
            jxc.setSup(jxcSup);
        }
        return jxcPurchases;
    }

    @Override
    public int insertPur(String s) {
        JxcPurchase jxcPurchase = new JxcPurchase();
        jxcPurchase.setPurOrderId(s);
        jxcPurchase.setPurVerify("1");
        return purMapper.insertPur(jxcPurchase);
    }
}
